#ifndef DISPLAY_H
#define DISPLAY_H

#include <zephyr/kernel.h>

#define DISPLAY_BLOCK_MAX_CNT 2
#define DISPLAY_MAX_FRAME 10
#define DISPLAY_MAX_COL 20
#define DISPLAY_MAX_ROW 20

enum play_mode_e
{
    PLAY_NOW,
    PLAY_QUEUE
};

enum cycle_mode_e
{
    CYCLE_ONCE,
    CYCLE_LOOP
};

struct bit_data_s
{
    uint8_t red;
    uint8_t green;
    uint8_t blue;
};

struct display_block_s
{
    uint16_t id;
    uint16_t frame;
    uint8_t col;
    uint8_t row;
    uint16_t inv_time_ms;
    bool is_playing;
    enum play_mode_e play_mode;
    enum cycle_mode_e cycle_mode;
    struct bit_data_s data[DISPLAY_MAX_FRAME][DISPLAY_MAX_COL][DISPLAY_MAX_ROW];
};

void display_block_init(void);
uint16_t get_idle_block(void);
void set_block_info(uint16_t id, uint16_t frame, uint8_t col, uint8_t row, uint16_t inv_time_ms);
uint16_t get_block_index(uint16_t id);
void set_block_data(uint16_t id, uint16_t frame, uint8_t col, uint8_t row, uint8_t red, uint8_t green, uint8_t blue);
void mark_block_playing(uint16_t id, bool is_playing);
void block_clear(uint16_t id);
struct bit_data_s get_pix_data(uint16_t id, uint16_t frame, uint8_t col, uint8_t row);
uint16_t get_inv_time_ms(uint16_t id);
uint16_t get_frame(uint16_t id);
uint8_t get_col(uint16_t id);
uint8_t get_row(uint16_t id);
uint8_t set_play_mode(uint16_t id, enum play_mode_e play_mode);
uint8_t set_cycle_mode(uint16_t id, enum cycle_mode_e cycle_mode);

#endif